var label_count = 25;
var release_count = 25;
var tag_count = 25;
var member_count = 25;

function addLabel()
{
	var div = document.getElementById('labels');

	var arr = getLabelValues();
	div.innerHTML += '<span id="label'+label_count+'"><input id="input_label_year'+label_count+'" type="text" class="flat" size="2" name="label_year'+label_count+'">&nbsp;<input id="input_label'+label_count+'" type="text" class="flat" size="22" maxlength="128" name="label'+label_count+'">&nbsp;<small><a href="#" class="button" onclick="removeLabel('+label_count+');">remove</a></small><br><br></span>';
	setLabelValues(arr);

	label_count++;
}

function removeLabel(id)
{
	var o = document.getElementById("label"+id);
	o.style.display='none';
	var i = document.getElementById('input_label'+id);
	i.value = '';
}

function getLabelValues()
{
	var div = document.getElementById('labels');
	var inputs = div.getElementsByTagName("input");
	var i = 0;
	var a = new Array();

	for(i = 0; i < inputs.length; i++)
	{
		a[i] = inputs[i].value;
	}

	return a;
}

function setLabelValues(arr)
{
	var div = document.getElementById('labels');
	var inputs = div.getElementsByTagName("input");

	for(var i in arr)
	{
		inputs[i].value = arr[i];
	}
}





function addRelease()
{
	var div = document.getElementById('releases');

	var arr = getReleaseValues();
	div.innerHTML += '<span id="release'+release_count+'"><input id="input_release_year'+release_count+'" type="text" class="flat" size="2" name="release_year'+release_count+'">&nbsp;<input id="input_release'+release_count+'" type="text" class="flat" size="22" maxlength="128" name="release'+release_count+'">&nbsp;<small><a href="#" class="button" onclick="removeRelease('+release_count+');">remove</a></small><br><br></span>';
	setReleaseValues(arr);

	release_count++;
}

function removeRelease(id)
{
	var o = document.getElementById("release"+id);
	o.style.display='none';
	var i = document.getElementById('input_release'+id);
	i.value = '';
}

function getReleaseValues()
{
	var div = document.getElementById('releases');
	var inputs = div.getElementsByTagName("input");
	var i = 0;
	var a = new Array();

	for(i = 0; i < inputs.length; i++)
	{
		a[i] = inputs[i].value;
	}

	return a;
}

function setReleaseValues(arr)
{
	var div = document.getElementById('releases');
	var inputs = div.getElementsByTagName("input");

	for(var i in arr)
	{
		inputs[i].value = arr[i];
	}
}





function addTag()
{
	var div = document.getElementById('tags');

	var arr = getTagValues();
	div.innerHTML += '<span id="tag'+tag_count+'"><input id="input_tag'+tag_count+'" type="text" class="flat" size="30" maxlength="128" name="tag'+tag_count+'">&nbsp;<small><a href="#" class="button" onclick="removeTag('+tag_count+');">remove</a></small><br><br></span>';
	setTagValues(arr);

	tag_count++;
}

function removeTag(id)
{
	var o = document.getElementById("tag"+id);
	o.style.display='none';
	var i = document.getElementById('input_tag'+id);
	i.value = '';
}

function getTagValues()
{
	var div = document.getElementById('tags');
	var inputs = div.getElementsByTagName("input");
	var i = 0;
	var a = new Array();

	for(i = 0; i < inputs.length; i++)
	{
		a[i] = inputs[i].value;
	}

	return a;
}

function setTagValues(arr)
{
	var div = document.getElementById('tags');
	var inputs = div.getElementsByTagName("input");

	for(var i in arr)
	{
		inputs[i].value = arr[i];
	}
}




function addMember()
{
	var div = document.getElementById('members');

	var arr = getMemberValues();
	div.innerHTML += '<span id="member'+member_count+'" ><input id="input_member_year_started'+member_count+'" type="text" class="flat" size="2" name="member_year_started'+member_count+'">&nbsp;<input id="input_member_year_finished'+member_count+'" type="text" class="flat" size="2" name="member_year_finished'+member_count+'">&nbsp;<input id="input_member'+member_count+'" type="text" class="flat" size="20" maxlength="128" name="member'+member_count+'">&nbsp;<small><a href="#" class="button" onclick="removeMember('+member_count+'); return false;">remove</a></small><br><br></span>';
	setMemberValues(arr);

	member_count++;
}

function removeMember(id)
{
	var o = document.getElementById("member"+id);
	o.style.display='none';
	var i = document.getElementById('input_member_year_started'+id);
	i.value = '';
        i = document.getElementById('input_member_year_finished'+id);
        i.value = '';
        i = document.getElementById('input_member'+id);
        i.value = '';
}

function getMemberValues()
{
	var div = document.getElementById('members');
	var inputs = div.getElementsByTagName("input");
	var i = 0;
	var a = new Array();

	for(i = 0; i < inputs.length; i++)
	{
		a[i] = inputs[i].value;
	}

	return a;
}

function setTagValues(arr)
{
	var div = document.getElementById('tags');
	var inputs = div.getElementsByTagName("input");

	for(var i in arr)
	{
		inputs[i].value = arr[i];
	}
}
